//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#include "emittertemplate.h"
#include "particletemplate.h"
//
namespace model
{
//EmitterTemplate::EmitterBlock
EmitterTemplate::EmitterBlock::EmitterBlock()
:
   name(""),amount(0),scale(0),synchronized(false),position(),angle(),angular_velocity(),particle(0),emitter(0)
{
}
EmitterTemplate::EmitterBlock::EmitterBlock(const EmitterTemplate::EmitterBlock& p_other) :
   name(p_other.name),amount(p_other.amount),scale(p_other.scale),synchronized(p_other.synchronized),position(p_other.position),angle(p_other.angle),angular_velocity(p_other.angular_velocity),particle(p_other.particle),emitter(p_other.emitter)
{
}
EmitterTemplate::EmitterBlock &EmitterTemplate::EmitterBlock::operator=(const EmitterTemplate::EmitterBlock &p_other)
{
   if(&p_other!=this)
   {
      name=p_other.name;
      amount=p_other.amount;
      scale=p_other.scale;
      synchronized=p_other.synchronized;
      position=p_other.position;
      angle=p_other.angle;
      angular_velocity=p_other.angular_velocity;
      particle=p_other.particle;
      emitter=p_other.emitter;
   }
   return *this;
}
//EmitterTemplate
EmitterTemplate::EmitterTemplate(QObject* p_parent)
:
   Identified(p_parent),name("")
{
}
EmitterTemplate::~EmitterTemplate()
{
}
//
QString EmitterTemplate::get_name()const
{
   return name;
}
void EmitterTemplate::set_name(QString p_name)
{
   name=p_name;
}
void EmitterTemplate::store_data(QDataStream &p_stream)const
{
   p_stream<<name;
   p_stream<<emitter_blocks;
}
void EmitterTemplate::restore_data(RestoreStream &p_stream)
{
   p_stream>>name;
   p_stream>>emitter_blocks;
}
}
//
QDataStream &operator<<(QDataStream &p_stream,const model::EmitterTemplate::EmitterBlock &p_eb)
{
   p_stream<<p_eb.name;
   p_stream<<p_eb.amount;
   p_stream<<p_eb.scale;
   p_stream<<p_eb.synchronized;
   p_stream<<p_eb.position;
   p_stream<<p_eb.angle;
   p_stream<<p_eb.angular_velocity;
   p_stream<<p_eb.particle;
   p_stream<<p_eb.emitter;
   return p_stream;
}
RestoreStream &operator>>(RestoreStream &p_stream,model::EmitterTemplate::EmitterBlock &p_eb)
{
   p_stream>>p_eb.name;
   p_stream>>p_eb.amount;
   p_stream>>p_eb.scale;
   p_stream>>p_eb.synchronized;
   p_stream>>p_eb.position;
   p_stream>>p_eb.angle;
   p_stream>>p_eb.angular_velocity;
   p_stream>>p_eb.particle;
   p_stream>>p_eb.emitter;
   return p_stream;
}
RestoreStream &operator>>(RestoreStream &p_stream,model::EmitterTemplate *&p_et)
{
   return Identified::restore_object(p_stream,p_et);
}
/*bool Identified::is_emitter_template() const
{
   return metaObject()->className()==model::EmitterTemplate::staticMetaObject.className();
}*/
